/***************************************************************************//**
 * @file GUI/PFD_ALT.h
 * @author  Marek M. Cel <marekcel@mscsim.org>
 *
 * @section LICENSE
 *
 * Copyright (C) 2013 Marek M. Cel
 *
 * This file is part of MScSim. You can redistribute and modify it under
 * the terms of GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.
 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Further information about the GNU General Public License can also be found
 * on the world wide web at http://www.gnu.org.
 ******************************************************************************/
#ifndef PFD_ALT_H
#define PFD_ALT_H

////////////////////////////////////////////////////////////////////////////////

#include <QGraphicsView>
#include <QGraphicsSvgItem>

////////////////////////////////////////////////////////////////////////////////

class PFD_ALT
{
public:

    /** */
    PFD_ALT( QGraphicsScene *scene );

    /** */
    void init( float scaleX, float scaleY );

    /** */
    void update( float scaleX, float scaleY );

    /** @param altitude (dimensionless numeric value) */
    void setAltitude( float altitude );

private:

    QGraphicsScene *m_scene;    ///< graphics scene

    QGraphicsSvgItem  *m_itemBack;
    QGraphicsSvgItem  *m_itemScale1;
    QGraphicsSvgItem  *m_itemScale2;
    QGraphicsTextItem *m_itemLabel1;
    QGraphicsTextItem *m_itemLabel2;
    QGraphicsTextItem *m_itemLabel3;
    QGraphicsSvgItem  *m_itemGround;
    QGraphicsSvgItem  *m_itemFrame;
    QGraphicsTextItem *m_itemAltitude;
    QGraphicsTextItem *m_itemPressure;

    QColor m_frameTextColor;
    QColor m_pressTextColor;
    QColor m_labelsColor;

    QFont  m_frameTextFont;
    QFont  m_labelsFont;

    float m_altitude;

    float m_scale1DeltaY_new;
    float m_scale1DeltaY_old;
    float m_scale2DeltaY_new;
    float m_scale2DeltaY_old;
    float m_groundDeltaY_new;
    float m_groundDeltaY_old;
    float m_labelsDeltaY_new;
    float m_labelsDeltaY_old;

    float m_scaleX;     ///<
    float m_scaleY;     ///<

    const float m_originalPixPerAlt;    ///< [px/altitude unit]
    const float m_originalScaleHeight;  ///< [px]
    const float m_originalLabelsX;      ///< [px]
    const float m_originalLabel1Y;      ///< [px]
    const float m_originalLabel2Y;      ///< [px]
    const float m_originalLabel3Y;      ///< [px]

    QPointF m_originalBackPos;
    QPointF m_originalScale1Pos;
    QPointF m_originalScale2Pos;
    QPointF m_originalGroundPos;
    QPointF m_originalFramePos;
    QPointF m_originalAltitudeCtr;
    QPointF m_originalPressureCtr;

    const int m_backZ;
    const int m_scaleZ;
    const int m_labelsZ;
    const int m_groundZ;
    const int m_frameZ;
    const int m_frameTextZ;

    /** */
    void reset();

    /** */
    void updateAltitude();

    /** */
    void updateScale();

    /** */
    void updateScaleLabels();
};

////////////////////////////////////////////////////////////////////////////////

#endif // PFD_ALT_H
